import React from "react";
import {Modal} from 'antd';
import LlxTable from '../LlxTable'
import { withRouter } from "react-router-dom";
import { connect } from 'react-redux'
import {addHistoryRouter} from 'redux/action'
const QuoteSubject = (props) => {
const {isModalVisible, setIsModalVisible,quoteData} = props

  
  const columns = [
    {title: '类型', dataIndex: 'type', key: 'type', align: 'center'},
    {title: '状态', dataIndex: 'workStatus', key: 'workStatus', align: 'center'},
    {title: '名称', dataIndex: 'name', key: 'name', align: 'center',render:(text,row)=>{
      return  <div className="text-link" onClick={()=>goPape(row)}>
       {text}
      </div>
    }},
]
  //2.确认  
  const handleOk = () => {
    setIsModalVisible(false);
  }
  //3.取消
  const handleCancel = () => {
    setIsModalVisible(false);
  };
  // 4.前往别的地方
  const goPape = (value) => {
      switch(value.type) {
        case '主题课':
          props.history.push('/view/plan/themeSubjectInfo?id=' + value.id)
          props.addRouter({
            menuName:'主题课详情',url:'plan/themeSubjectInfo?id=' + value.id 
          })
        break
        case '精读书':
          props.history.push('/view/book/intensiveBookInfo?id=' + value.id)
          props.addRouter({
            menuName:'精读书详情',url:'book/intensiveBookInfo?id=' + value.id 
          })
        break
        case '试卷':
          props.history.push('/view/test/testPaperInfo?id=' + value.id)
          props.addRouter({
            menuName:'试卷详情',url:'test/testPaperInfo?id=' + value.id 
          })
        break
        default:
          return
      }
  }
  
  return   <Modal  onCancel={handleCancel} width={700} onOk={handleOk} title="题目引用列表" visible={isModalVisible}>
      {/* 表格 */}
     <LlxTable
      selectedRowShow={false}
      height={450}
      paginationHide={true}
      columns={columns}
      dataSource={quoteData}/>
   </Modal>

}

const mapDispatchToProps = (dispatch) => {
  return {
    addRouter: (route) => dispatch(addHistoryRouter(route)),
  }
}
export default connect(null,mapDispatchToProps)(withRouter(QuoteSubject))